package com.alks.function.controller.stockdept.pcfactorystockquery;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.entity.HgMtlRelation;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.stockdept.pcfactorystockwork.*;
import com.alks.function.service.stockdept.pcfactorystockquery.IPcMtlUDService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

@RestController
@ApiRestController("/pcFactorStockQuery")
@Api(value = "仓储部查询",tags = "仓储部-仓储工厂作业-材料入库删除修改")
@Slf4j
@RoleCheck(prgIds = {"160105"})
public class PcMtlUDController {
    @Autowired
    IPcMtlUDService udService;

    @WebLogger
    @PutMapping("/inStockDetailQuery")
    @ApiOperation(value = "材料入库删除修改-入库明细查询-分页可条件查询",tags = "仓储部-仓储工厂作业-材料入库删除修改")
    public ResponseInfo inStockDetailQuery(@RequestBody IStockDtlRequest request){
        return udService.inStockDetailQuery(request);
    }

    @WebLogger
    @GetMapping("/delateByRecNo")
    @ApiOperation(value = "材料入库删除修改-整单删除-删除",tags = "仓储部-仓储工厂作业-材料入库删除修改")
    public ResponseInfo delateByRecNo(@RequestParam String recNo){
        return udService.delateByRecNo(recNo);
    }

    @WebLogger
    @PostMapping("/deleteRow")
    @ApiOperation(value = "材料入库删除修改-当前行删除-删除",tags = "仓储部-仓储工厂作业-材料入库删除修改")
    public ResponseInfo deleteRow(@RequestParam Integer primaryId){
        return udService.deleteRow(primaryId);
    }

    @WebLogger
    @PostMapping("/sendQtyUpdate")
    @ApiOperation(value = "材料入库删除修改-数量修改-修改",tags = "仓储部-仓储工厂作业-材料入库删除修改")
    public ResponseInfo sendQtyUpdate(@RequestParam Integer id,
                                      @RequestParam BigDecimal sendQty){
        return udService.sendQtyUpdate(id,sendQty);
    }

    @WebLogger
    @PutMapping("/mtlNoHgUpdate")
    @ApiOperation(value = "海关编码修改",tags = "仓储部-仓储工厂作业-材料入库删除修改")
    public ResponseInfo<Void> sendQtyUpdate(@RequestBody HgMtlRelation relation){
        udService.mtlNoHgUpdate(relation);
        return ResponseInfo.ok();
    }

    @WebLogger
    @PutMapping("/otherDateUpdate/{recNo}")
    @ApiOperation(value = "材料入库删除修改-其他修改-修改",tags = "仓储部-仓储工厂作业-材料入库删除修改")
    public ResponseInfo otherDateUpdate(@RequestBody OtherStockUpRequest request,
                                        @PathVariable String recNo){
         udService.otherDateUpdate(request,recNo);
         return ResponseInfo.ok();
    }

    @WebLogger
    @PutMapping("/mtlSubQuery")
    @ApiOperation(value = "材料入库删除修改-材料替代查询-可条件查询",tags = "仓储部-仓储工厂作业-材料入库删除修改")
    public ResponseInfo mtlSubQuery(@RequestBody MtlSubQueryRequest request){
        return udService.mtlSubQuery(request);
    }

    @WebLogger
    @PutMapping("/inStockMtlSub")
    @ApiOperation(value = "材料入库删除修改-材料替代-新增",tags = "仓储部-仓储工厂作业-材料入库删除修改")
    public ResponseInfo inStockMtlSub(@RequestBody MtlSubAddRequest request){
        return udService.inStockMtlSub(request);
    }

    @WebLogger
    @PutMapping("/subMtlQuery")
    @ApiOperation(value = "材料入库删除修改-替代用材料查询-分页可条件查询",tags = "仓储部-仓储工厂作业-材料入库删除修改")
    public ResponseInfo subMtlQuery(@RequestBody SubMtlQueryRequest request){
        return udService.subMtlQuery(request);
    }

    @WebLogger
    @PutMapping("/mtlSubUpdate")
    @ApiOperation(value = "材料入库删除修改-材料替代数据修改-批量修改",tags = "仓储部-仓储工厂作业-材料入库删除修改")
    public ResponseInfo mtlSubUpdate(@RequestBody List<MtlSubUpdateRequest> request){
        return udService.mtlSubUpdate(request);
    }

    @WebLogger
    @PutMapping("/MtlSubProcess")
    @ApiOperation(value = "材料入库删除修改-材料替换处理-修改",tags = "仓储部-仓储工厂作业-材料入库删除修改")
    public ResponseInfo MtlSubProcess(@RequestBody MtlSubProcRequest request){
        return udService.MtlSubProcess(request);
    }
}
